<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form action="/action_page.php" method="post">
    <p><span>用户名： </span><input type="text" id="username" required></p>
    <p><span>性  别：</span><input type="radio" name="gender" id='boy' value="m">男
                           <input type="radio" name="gender" id='girl' value="f">女
    </p>
    <input type="submit">
</form>

<script>
    var input_text = document.getElementById("username");
    var boy_radio =  document.getElementById("boy");
    var girl_radio  =  document.getElementById("girl");
        boy_radio.checked // 查看返回的结果是否为true，true被选中
        girl_radio.checked = true;
</script>
</body>
</html>